Compute effects for indirect calls in GlobalEffects#8609
Compute effects for indirect calls in GlobalEffects#8609stevenfontanella wants to merge 19 commits intomainfrom
Conversation
b7ce0b6 to
9fcf76b
Compare
9fcf76b to
0e28a7a
Compare
0e28a7a to
83f4b3b
Compare
83f4b3b to
3a25c2e
Compare
|
Also added some tests exercising call_indirect. |
We don't need to walk up the supertype chain for type targets of indirect calls, we already do that for function implementations which would reach the type of the indirect call anyway
|
Added a test showing two different effect types being aggregated into the same function (global-effects-closed-world-simplify-locals.wast). |
The test went wrong at some point, let me update. |
It turns out that the effects were pessimized when changing the features from |
| if (!closedWorld) { | ||
| for (const auto& [caller, callerInfo] : funcInfos) { |
There was a problem hiding this comment.
Don't we have to add the function -> function direct call edges whether or not we're in a closed world? I would expect this condition to guard just the early return below.
| if (visited.contains(t)) { | ||
| return; | ||
| } | ||
|
|
||
| visited.insert(t); |
There was a problem hiding this comment.
Can combine these lookups by using the bool result of insert.
When running in --closed-world, compute effects for indirect calls by unioning the effects of all potential functions of that type. In --closed-world, we assume that all references originate in our module, so the only possible functions that we don't know about are imports. Previously we gave up on effects analysis for indirect calls.
Yields a very small byte count reduction in calcworker (3799354 - 3799297 = 57 bytes). Also shows no significant difference in Binaryen runtime: (0.1346069 -> 0.13375045 = <1% improvement, probably within noise). We expect more benefits after we're able to share indirect call effects with other passes, since currently they're only seen one layer up for callers of functions that indirectly call functions (see the newly-added tests for examples).
Followups:
Part of #8615.